package structures;

import java.text.MessageFormat;

/**
 * Queries for the database
 * 
 * @author Jose Antonio Prieto
 */
public class Query {

	// ========== Image Querys ==========

	/** Query - IMAGE: Image Id from Id given */
	private String imageIdFromOwner;
	/** Query - IMAGE: Image Information from Email given */
	private String imageInfoFromOwner;
	/** Query - IMAGE: Image Information from Id given */
	private String imageInfoFromId;
	/** Query - IMAGE: Image Exif from Id given */
	private String imageExifFromId;
	/** Query - IMAGE: Image Exif field from Id given */
	private String imageExifFieldFromId;
	/** Query - IMAGE: Image Application properties from Id given */
	private String imageAppPropertiesFromId;
	/** Query - IMAGE: Image Application properties field from Id given */
	private String imageAppPropertiesFieldFromId;
	/** Query - IMAGE: Image Id from free tag given */
	private String imageIdFromFreeTag;
	/** Query - IMAGE: Image Id from free tag given */
	private String imageIdListFromPreDefinedTag;
	/** Query - IMAGE: Image URL from Id given */
	private String imageURLFromId;
	/** Query - IMAGE: Image Id from URL given */
	private String imageIdFromURL;
	/** Query - IMAGE: Add a basic image */
	private String addBasicImage;
	/** Query - IMAGE: Delete an image */
	private String deleteImage;
	/** Query - IMAGE: Modify an image exif field */
	private String modifyImageExif;
	/** Query - IMAGE: Modify an image properties field */
	private String modifyImageProperties;
	/** Query - IMAGE: Modify an image rank field */
	private String modifyImageRank;
	/** Query - IMAGE: Add a free tag to the image */
	private String addFreeTagToImage;
	/** Query - IMAGE: Add a pre-defined tag to the image */
	private String addPreDefinedTagToImage;
	/** Query - IMAGE: Add a free region tag to the image */
	private String addFreeRegionTagToImage;
	/** Query - IMAGE: Add a pre-defined region tag to the image */
	private String addPreDefinedRegionTagToImage;
	/** Query - IMAGE: Delete a tag to the image */
	private String deleteTagToImage;
	/** Query - IMAGE: Next image id available */
	private String nextImageId;

	// ========== Video Querys ==========

	/** Query - VIDEO: Video Id from Owner given */
	private String videoIdFromOwner;
	/** Query - VIDEO: Video Information from Owner given */
	private String videoInfoFromOwner;
	/** Query - VIDEO: Video Information from Id given */
	private String videoInfoFromId;
	/** Query - VIDEO: Video Information field from Owner given*/
	private String videoInfoFieldFromId;
	/** Query - VIDEO: Video list Id from free tag given */
	private String videoIdListFromFreeTag;
	/** Query - VIDEO: Video list Id from pre-defined tag given */
	private String videoIdListFromPreDefinedTag;
	/** Query - VIDEO: Video URL from Id given*/
	private String videoURLFromId;
    /** Query - VIDEO: Video Id from URL given*/
    private String videoIdFromURL;
	/** Query - VIDEO: Add a Video */
	private String addBasicVideo;
	/** Query - VIDEO: Delete a Video */
	private String deleteVideo;
	/** Query - VIDEO: Modify a Video field */
	private String modifyVideoField;
	/** Query - VIDEO: Modify a Video rate */
	private String modifyVideoRate;
	/** Query - VIDEO: Add a free tag to a Video */
	private String addFreeTagToVideo;
	/** Query - VIDEO: Add a pre-defined tag to a Video */
	private String addPreDefinedTagToVideo;
	/** Query - VIDEO: Delete a tag to a Video */
	private String deleteTagToVideo;
	/** Query - VIDEO: Next video id available */
	private String nextVideoId;

	// ========== Notice Querys ==========

	/** Query - NOTICE: Notice Id list from Owner given */
	private String noticeIdListFromOwner;
	/** Query - NOTICE: Notice Information lists from Owner given */
	private String noticeInfoFromOwner;
	/** Query - NOTICE: Notice Information lists from Id given */
	private String noticeInfoFromId;
	/** Query - NOTICE: Notice Id list from containing a certain word at any paragraph */
	private String noticeIdFromKeywordInAnyParagraph;
	/** Query - NOTICE: Image URL from any Notice Title containing a certain word */
	private String imURLFromAnyNoticeTitContKw;
	/** Query - NOTICE: Image URL from any Notice Paragraph containing a certain word */
	private String imURLFromAnyNoticeParContKw;
	/** Query - NOTICE: Image URL from any Notice Paragraph containing a certain word 
	 * into a preceding or following paragraph */
	private String imURLFromAnyNoticeParContKwPredAnt;
	/** Query - NOTICE: Delete a notice */
	private String deleteNotice;
	/** Query - NOTICE: Next notice id available */
	private String nextNoticeId;
	
	// ========== User Querys ==========

	/** Query - USER: User information from Owner given */
	private String userInfoFromOwner;
	/** Query - USER: User information from Id given */
	private String userInfoFromId;
	/** Query - USER: User information field from Owner given */
	private String userInfoFieldFromOwner;
	/** Query - USER: User home directory from Owner given */
	private String userHomeDirectoryFromOwner;
	/** Query - USER: User home directory from Id given */
	private String userHomeDirectoryFromId;
	/** Query - USER: Add a user */
	private String addUser;
	/** Query - USER: Delete a user */
	private String deleteUser;
	/** Query - USER: Modify user field */
	private String modifyUserField;
	/** Query - USER: Modify user name */
	private String modifyUserName;
	/** Query - USER: Next user id available */
	private String nextUserId;
	
	
	/** Constructor */
	public Query() {
	}

	/**
	 * This function initialices the IMAGE related Query's
	 */
	public void loadQuerys() {

		// ========= Image Querys  ========= 
		
		imageIdFromOwner = "for $a in doc(\"images_db.xml\")/images/image[@owner=\"{0}\"]"
				+ "return <id>'{'string($a/@id)'}'</id>";

		imageInfoFromOwner = "doc(\"images_db.xml\")/images/image[@owner=\"{0}\"]";

		imageInfoFromId = "doc(\"images_db.xml\")/images/image[@id=\"{0}\"]";

		imageExifFromId = "doc(\"images_db.xml\")/images/image[@id=\"{0}\"]/exif";

		imageExifFieldFromId = "doc(\"images_db.xml\")/images/image[@id=\"{0}\"]/exif/{1}";

		imageAppPropertiesFromId = "doc(\"images_db.xml\")/images/image[@id=\"{0}\"]/properties";

		imageAppPropertiesFieldFromId = "doc(\"images_db.xml\")/images/image[@id=\"{0}\"]/properties/{1}";

		imageIdFromFreeTag = "for $b in doc(\"images_db.xml\")/images/image "
				+ "where $b/properties/tags/tag[tagname=\"{0}\"] "
				+ "return <id>'{'string($b/@id)'}'</id>";

		imageIdListFromPreDefinedTag = "for $a in doc(\"{0}\")//name[.=\"{1}\"]/..//name, "
				+ "$b in doc(\"images_db.xml\")/images/image "
				+ "where $b/properties/tags/tag[tagname=$a] "
				+ "return <id>'{'string($b/@id)'}'</id>";

		imageURLFromId = "for $a in doc(\"images_db.xml\")/images/image " +
				"where $a/@id=\"{0}\" " +
				"return <URL> '{'" +
				"for $b in doc(\"users_db.xml\")/users/user " +
				"where $a/@owner=$b/email " +
				"return string($b/userDirectory)}/'{'string($a/properties/title)'}'</URL>";
	
		imageIdFromURL = "for $a in doc(\"images_db.xml\")/images/image " +
				"return " +
				"for $c in doc(\"users_db.xml\")/users/user " +
				"where $a/@owner=$c/email " +
				"return " +
				"for $e in ('{0}') " +
				"where $e = concat(string($c/userDirectory),\"/\",string($a/properties/title)) " +
				"return <id>{string($a/@id)}</id>";
		
		addBasicImage = 
			"update insert <image id=\"{0}\" owner=\"{1}\"> " +
			"<exif> <make></make> <model></model> <software></software> <bitsPerSample></bitsPerSample> " +
			"<compression></compression> <imageDescription></imageDescription> <dateTime></dateTime> " +
			"<artist></artist> <copyright></copyright> <flash></flash> <userComment></userComment> </exif> " +
			"<properties> <title>{2}</title> <place></place> <rate> <interest>5</interest> " +
			"<quality>5</quality> <global>5</global> </rate> <tags></tags> </properties> </image> " +
			"into /images";
		
		deleteImage = "update delete /images/image[@id=\"{0}\"]";
		
		modifyImageExif = "update replace /images/image[@id=\"{0}\"]/exif/{1} with <{1}>{2}</{1}>";

		modifyImageProperties = "update replace /images/image[@id=\"{0}\"]/properties/{1} with <{1}>{2}</{1}>";

		modifyImageRank = "update replace /images/image[@id=\"{0}\"]/properties/rate/{1} with <{1}>{2}</{1}>";

		addFreeTagToImage = "for $a in /images/image[@id=\"{0}\"] " +
			"where (count($a/properties/tags/tag[tagname=\"{1}\"])<1) " +
			"return " +
			"update insert " +
			"<tag>" +
			"  <tagname>{1}</tagname>" +
			"</tag> " +
			"into $a/properties/tags";

		addPreDefinedTagToImage = "for $a in /images/image[@id=\"{0}\"] " +
				"where (count($a/properties/tags/tag[tagname=\"{2}\"])<1) " +
				"return " +
				"update insert " +
				"<tag taxonomy=\"{1}\">" +
				"  <tagname>{2}</tagname>" +
				"</tag>" +
				"into $a/properties/tags";

		addFreeRegionTagToImage = "update insert " +
				"<tag>" +
				"  <tagname>{1}</tagname>" +
				"  <regions>" +
				"    <region>" +
				"      <coordinates>" +
				"        <initCoordinateX>{2}</initCoordinateX>" +
				"        <endCoordinateX>{3}</endCoordinateX>" +
				"        <initCoordinateY>{4}</initCoordinateY>" +
				"        <endCoordinateY>{5}</endCoordinateY>" +
				"      </coordinates>" +
				"    </region>" +
				"  </regions>" +
				"</tag>" +
				"into /images/image[@id=\"{0}\"]/properties/tags";

		addPreDefinedRegionTagToImage = "update insert " +
				"<tag taxonomy=\"{1}\"> " +
				"  <tagname>{2}</tagname> " +
				"  <regions> " +
				"    <region> " +
				"      <coordinates> " +
				"        <initCoordinateX>{3}</initCoordinateX> " +
				"        <endCoordinateX>{4}</endCoordinateX> " +
				"        <initCoordinateY>{5}</initCoordinateY> " +
				"        <endCoordinateY>{6}</endCoordinateY> " +
				"      </coordinates> " +
				"    </region> " +
				"  </regions> " +
				"</tag> " +
				"into /images/image[@id=\"{0}\"]/properties/tags";

		deleteTagToImage = "update delete /images/image[@id=\"{0}\"]/properties/tags/tag[tagname=\"{1}\"]";
		
		nextImageId = "let $max := (for $b in //image order by $b/@id descending return string($b/@id)) " +
				"let $max := concat(\"i\",string(xs:int(substring(subsequence($max,1,1),2))+1)) " +
				"return <nextID>'{'$max'}'</nextID>";
		
		// ========= Video Querys  ========= 
		
		videoIdFromOwner = "for $a in doc(\"videos_db.xml\")/videos/video[@owner=\"{0}\"] "
				+ "return <id>'{'string($a/@id)'}'</id>";

		videoInfoFromOwner = "doc(\"videos_db.xml\")/videos/video[@owner=\"{0}\"]";

		videoInfoFromId = "doc(\"videos_db.xml\")/videos/video[@id=\"{0}\"]";

		videoInfoFieldFromId = "doc(\"videos_db.xml\")/videos/video[@id=\"{0}\"]/{1}";

		videoIdListFromFreeTag = "for $b in doc(\"videos_db.xml\")/videos/video "
				+ "where $b/tags/tag[tagname=\"{0}\"] "
				+ "return <id>'{'string($b/@id)'}'</id>";

		videoIdListFromPreDefinedTag = "for $a in doc(\"{0}\")//name[.=\"{1}\"]/..//name, "
				+ "$b in doc(\"videos_db.xml\")/videos/video "
				+ "where $b/tags/tag[tagname=$a] "
				+ "return <id>'{'string($b/@id)'}'</id>";

		videoURLFromId = "for $a in doc(\"videos_db.xml\")/videos/video " +
				"where $a/@id=\"{0}\" " +
				"return <URL>{ " +
				"for $b in doc(\"users_db.xml\")/users/user " +
				"where $a/@owner=$b/email " +
				"return string($b/userDirectory)}/'{'string($a/title)'}'</URL>";

        videoIdFromURL = "for $a in doc(\"videos_db.xml\")/videos/video " +
				"return " +
				"for $c in doc(\"users_db.xml\")/users/user " +
				"where $a/@owner=$c/email " +
				"return " +
				"for $e in ('{0}') " +
				"where $e = concat(string($c/userDirectory),\"/\",string($a/title)) " +
				"return <id>{string($a/@id)}</id>";

		addBasicVideo = "update insert " +
				"<video id=\"{0}\" owner=\"{1}\">" +
				"  <title>{2}</title>" +
				"  <place></place>" +
				"  <videoDescription></videoDescription>" +
				"  <dateTime></dateTime>" +
				"  <userComment></userComment>" +
				"  <rate>" +
				"    <interest>5</interest>" +
				"    <quality>5</quality>" +
				"    <global>5</global>" +
				"  </rate>" +
				"  <tags></tags>" +
				"</video>" +
				"into /videos";

		deleteVideo = "update delete /videos/video[@id=\"{0}\"]";

		modifyVideoField = "update replace /videos/video[@id=\"{0}\"]/{1} with <{1}>{2}</{1}>";

		modifyVideoRate = "update replace /videos/video[@id=\"{0}\"]/rate/{1} with <{1}>{2}</{1}>";

		addFreeTagToVideo = "for $a in /videos/video[@id=\"{0}\"] " +
				"where (count($a/tags/tag[tagname=\"{1}\"])<1) " +
				"return " +
				"update insert " +
				"<tag> " +
				"  <tagname>{1}</tagname> " +
				"</tag> " +
				"into $a/tags";

		addPreDefinedTagToVideo = "for $a in /videos/video[@id=\"{0}\"] " +
				"where (count($a/tags/tag[tagname=\"{2}\"])<1) " +
				"return " +
				"update insert " +
				"<tag taxonomy=\"{1}\"> " +
				"  <tagname>{2}</tagname> " +
				"</tag> " +
				"into $a/tags";
		
		deleteTagToVideo = "update delete /videos/video[@id=\"{0}\"]/tags/tag[tagname=\"{1}\"]";
		
		nextVideoId = "let $max := (for $b in //video order by $b/@id descending return string($b/@id)) " +
				"let $max := concat(\"v\",string(xs:int(substring(subsequence($max,1,1),2))+1)) " +
				"return <nextID>'{'$max'}'</nextID>";
		
		// ========= Notice Querys  ========= 
		
		noticeIdListFromOwner = 
			"for $a in doc(\"notices_db.xml\")/notices/news[@owner=\"{0}\"] " +
			"return <id>'{'string($a/@id)'}'</id>";
		
		noticeInfoFromOwner = "doc(\"notices_db.xml\")/notices/news[@owner=\"{0}\"]";
		
		noticeInfoFromId = "doc(\"notices_db.xml\")/notices/news[@id=\"{0}\"]";
		
		noticeIdFromKeywordInAnyParagraph = 
			"for $b in doc(\"notices_db.xml\")/notices/news " +
			"where $b/noticeContent/paragraph[contains(.,\"{0}\")]" +
			"return <id>'{'string($b/@id)'}'</id>";
		
		imURLFromAnyNoticeTitContKw = 
			"for $a in doc(\"notices_db.xml\")/notices/news/title[contains(.,\"{0}\")] " +
			"return <news id=\"'{'string($a/../@id)'}'\" owner=\"'{'$a/../@owner'}'\">'{' " +
			"for $b in $a/../noticeContent/picture " +
			"return <URL>'{' for $c in doc(\"users_db.xml\")/users/user " +
			"where $a/../@owner=$c/email " +
			"return string($c/userDirectory)'}'/'{'string($b)'}'</URL>'}'</news>";
		
		imURLFromAnyNoticeParContKw = 
			"for $a in doc(\"notices_db.xml\")/notices/news " +
			"where $a/noticeContent/paragraph[contains(.,\"{0}\")] " +
			"return <news id=\"'{'string($a/@id)'}'\" owner=\"'{'string($a/@owner)'}'\">'{' " +
			"for $b in $a/noticeContent/picture " +
			"return <URL>'{' for $c in doc(\"users_db.xml\")/users/user " +
			"where $a/@owner=$c/email " +
			"return string($c/userDirectory)'}'/'{'string($b)'}'</URL>'}'</news>";
		
		imURLFromAnyNoticeParContKwPredAnt = 
			"for $a in doc(\"notices_db.xml\")/notices/news/noticeContent/picture " +
			"return ( if(name($a/preceding-sibling::*[1])=\"paragraph\" " +
			"and contains($a/preceding-sibling::*[1], \"{0}\")) " +
			"then <URL>'{' " +
			"for $b in doc(\"users_db.xml\")/users/user " +
			"where $a/../../@owner=$b/email " +
			"return string($b/userDirectory)'}'/'{'string($a)'}'</URL> " +
			"else if(name($a/following-sibling::*[1])=\"paragraph\" " +
			"and contains($a/following-sibling::*[1], \"{0}\")) " +
			"then <URL>'{' " +
			"for $b in doc(\"users_db.xml\")/users/user " +
			"where $a/../../@owner=$b/email " +
			"return string($b/userDirectory)'}'/'{'string($a)'}'</URL> else())";
		
		deleteNotice = "update delete /notices/news[@id=\"{0}\"]";
		
		nextNoticeId = "let $max := (for $b in //news order by $b/@id descending return string($b/@id)) " +
				"let $max := concat(\"n\",string(xs:int(substring(subsequence($max,1,1),2))+1)) " +
				"return <nextID>'{'$max'}'</nextID>";
		
		// ========= Users Querys  ========= 
		
		userInfoFromOwner = "doc(\"users_db.xml\")//user[email=\"{0}\"]";
		
		userInfoFromId = "doc(\"users_db.xml\")//user[@id=\"{0}\"]";
		
		userInfoFieldFromOwner = "doc(\"users_db.xml\")//user[email=\"{0}\"]/{1}";
		
		userHomeDirectoryFromOwner = 
			"doc(\"users_db.xml\")//user[email=\"{0}\"]/userDirectory";
		
		userHomeDirectoryFromId = "doc(\"users_db.xml\")//user[@id=\"{0}\"]/userDirectory";
		
		addUser = "update insert " +
				"<user id=\"{0}\"> " +
				"  <name> " +
				"    <firstName>{1}</firstName>	" +
				"    <lastName>{2}</lastName>	" +
				"  </name>	" +
				"  <nickName>{3}</nickName>	" +
				"  <userDirectory>{4}</userDirectory>	" +
				"  <email>{5}</email>	" +
				"</user> " +
				"into /users";

		deleteUser = "update delete /users/user[@id=\"{0}\"]";

		modifyUserField = "update replace /users/user[@id=\"{0}\"]/{1} with <{1}>{2}</{1}>";

		modifyUserName = "update replace /users/user[@id=\"{0}\"]/name/{1} with <{1}>{2}</{1}>";
		
		nextUserId = "let $max := (for $b in //user order by $b/@id descending return string($b/@id)) " +
				"let $max := concat(\"u\",string(xs:int(substring(subsequence($max,1,1),2))+1)) " +
				"return <nextID>'{'$max'}'</nextID>";
	}

	/**
	 * Getter
	 * @param owner
	 * @return the noticeIdListFromOwner
	 */
	public String getNoticeIdListFromOwner(String owner) {
		if(!owner.equals(null)){
			Object[] params = {owner};
			return new MessageFormat(noticeIdListFromOwner).format(params);
		}
		return null;
	}

	/**
	 * Getter
	 * @param owner
	 * @return the noticeInfoFromOwner
	 */
	public String getNoticeInfoFromOwner(String owner) {
		if(!owner.equals(null)){
			Object[] params = {owner};
			return new MessageFormat(noticeInfoFromOwner).format(params);
		}
		return null;
	}

	/**
	 * Getter
	 * @param id
	 * @return the noticeInfoFromId
	 */
	public String getNoticeInfoFromId(String id) {
		if(!id.equals(null)){
			Object[] params = {id};
			return new MessageFormat(noticeInfoFromId).format(params);
		}
		return null;
	}

	/**
	 * Getter
	 * @param keyword
	 * @return the noticeIdFromKeywordInAnyParagraph
	 */
	public String getNoticeIdFromKeywordInAnyParagraph(String keyword) {
		if(!keyword.equals(null)){
			Object[] params = {keyword};
			return new MessageFormat(noticeIdFromKeywordInAnyParagraph).format(params);
		}
		return null;
	}

	/**
	 * Getter
	 * @param keyword
	 * @return the imURLFromAnyNoticeTitContKw
	 */
	public String getImURLFromAnyNoticeTitContKw(String keyword) {
		if(!keyword.equals(null)){
			Object[] params = {keyword};
			return new MessageFormat(imURLFromAnyNoticeTitContKw).format(params);
		}
		return null;
	}

	/**
	 * Getter
	 * @param keyword
	 * @return the imURLFromAnyNoticeParContKw
	 */
	public String getImURLFromAnyNoticeParContKw(String keyword) {
		if(!keyword.equals(null)){
			Object[] params = {keyword};
			return new MessageFormat(imURLFromAnyNoticeParContKw).format(params);
		}
		return null;
	}

	/**
	 * Getter
	 * @param keyword
	 * @return the imURLFromAnyNoticeParContKwPredAnt
	 */
	public String getImURLFromAnyNoticeParContKwPredAnt(String keyword) {
		if(!keyword.equals(null)){
			Object[] params = {keyword};
			return new MessageFormat(imURLFromAnyNoticeParContKwPredAnt).format(params);
		}
		return null;
	}

	/**
	 * Getter
	 * @param owner
	 * @return the userInfoFromOwner
	 */
	public String getUserInfoFromOwner(String owner) {
		if(!owner.equals(null)){
			Object[] params = {owner};
			return new MessageFormat(userInfoFromOwner).format(params);
		}
		return null;
	}

	/**
	 * Getter
	 * @param id
	 * @return the userInfoFromId
	 */
	public String getUserInfoFromId(String id) {
		if(!id.equals(null)){
			Object[] params = {id};
			return new MessageFormat(userInfoFromId).format(params);
		}
		return null;
	}

	/**
	 * Getter
	 * @param owner
	 * @return the userInfoFieldFromOwner
	 */
	public String getUserInfoFieldFromOwner(String owner) {
		if(!owner.equals(null)){
			Object[] params = {owner};
			return new MessageFormat(userInfoFieldFromOwner).format(params);
		}
		return null;
	}

	/**
	 * Getter
	 * @param owner
	 * @return the userHomeDirectoryFromOwner
	 */
	public String getUserHomeDirectoryFromOwner(String owner) {
		if(!owner.equals(null)){
			Object[] params = {owner};
			return new MessageFormat(userHomeDirectoryFromOwner).format(params);
		}
		return null;
	}

	/** 
	 * Getter
	 * @param id
	 * @return the userHomeDirectoryFromId
	 */
	public String getUserHomeDirectoryFromId(String id) {
		if (!id.equals(null)) {
			Object[] params = {id};
			return new MessageFormat(userHomeDirectoryFromId).format(params);
		}
		return null;
	}

	/**
	 * Getter
	 * @param id
	 * @return the videoURLFromId 
	 */
	public String getVideoURLFromId(String id) {
		if (!id.equals(null)) {
			Object[] params = {id};
			return new MessageFormat(videoURLFromId).format(params);
		}
		return null;
	}


	/**
	 * Getter
	 * @param taxonomy
	 * @param tagname
	 * @return the videoIdListFromPreDefinedTag
	 */
	public String getVideoIdListFromPreDefinedTag(String taxonomy, String tagname) {
		if(!taxonomy.equals(null) && !tagname.equals(null)){
			Object[] params = {taxonomy,tagname};
			return new MessageFormat(videoIdListFromPreDefinedTag).format(params);
		}
		return null;
	}


	/**
	 * Getter
	 * @param tagname
	 * @return the videoIdListFromFreeTag
	 */
	public String getVideoIdListFromFreeTag(String tagname) {
		if(!tagname.equals(null)){
			Object[] params = {tagname};
			return new MessageFormat(videoIdListFromFreeTag).format(params);
		}
		return null;
	}

	/**
	 * Getter
	 * @param id
	 * @return the videoInfoFieldFromId
	 */
	public String getVideoInfoFieldFromId(String id) {
		if(!id.equals(null)){
			Object[] params = {id};
			return new MessageFormat(videoInfoFieldFromId).format(params);
		}
		return null;
	}

	/**
	 * Getter
	 * @param id
	 * @return the videoInfoFromId
	 */
	public String getVideoInfoFromId(String id) {
		if(!id.equals(null)){
			Object[] params = {id};
			return new MessageFormat(videoInfoFromId).format(params);
		}
		return null;
	}

	/**
	 * Getter
	 * @param owner
	 * @return the videoInfoFromOwner
	 */
	public String getVideoInfoFromOwner(String owner) {
		if(!owner.equals(null)){
			Object[] params = {owner};
			return new MessageFormat(videoInfoFromOwner).format(params);
		}
		return null;
	}

	/**
	 * Getter
	 * @param owner
	 * @return the videoIdFromOwner
	 */
	public String getVideoIdFromOwner(String owner) {
		if(!owner.equals(null)){
			Object[] params = {owner};
			return new MessageFormat(videoIdFromOwner).format(params);
		}
		return null;
	}

	/**
	 * Getter
	 * @param owner
	 * @return the imageIdFromOwner
	 */
	public String getImageIdFromOwner(String owner) {
		if(!owner.equals(null)){
			Object[] params = {owner};
			return new MessageFormat(imageIdFromOwner).format(params);
		}
		return null;
	}

	/**
	 * Getter
	 * @param owner
	 * @return the imageInfoFromOwner
	 */
	public String getImageInfoFromOwner(String owner) {
		if(!owner.equals(null)){
			Object[] params = {owner};
			return new MessageFormat(imageInfoFromOwner).format(params);
		}
		return null;
	}

	/**
	 * Getter
	 * @param id
	 * @return the imageInfoFromId
	 */
	public String getImageInfoFromId(String id) {
		if(!id.equals(null)){
			Object[] params = {id};
			return new MessageFormat(imageInfoFromId).format(params);
		}
		return null;
	}

	/**
	 * Getter
	 * @param id
	 * @return the imageExifFromId
	 */
	public String getImageExifFromId(String id) {
		if(!id.equals(null)){
			Object[] params = {id};
			return new MessageFormat(imageExifFromId).format(params);
		}
		return null;
	}

	/**
	 * Getter
	 * @param id
	 * @return the imageExifFieldFromId
	 */
	public String getImageExifFieldFromId(String id) {
		if(!id.equals(null)){
			Object[] params = {id};
			return new MessageFormat(imageExifFieldFromId).format(params);
		}
		return null;
	}

	/**
	 * Getter
	 * @param id
	 * @return the imageAppPropertiesFromId
	 */
	public String getImageAppPropertiesFromId(String id) {
		if(!id.equals(null)){
			Object[] params = {id};
			return new MessageFormat(imageAppPropertiesFromId).format(params);
		}
		return null;
	}

	/**
	 * Getter
	 * @param id
	 * @return the imageAppPropertiesFieldFromId
	 */
	public String getImageAppPropertiesFieldFromId(String id) {
		if(!id.equals(null)){
			Object[] params = {id};
			return new MessageFormat(imageAppPropertiesFieldFromId).format(params);
		}
		return null;
	}

	/**
	 * Getter
	 * @param tagname
	 * @return the imageIdFromFreeTag
	 */
	public String getImageIdFromFreeTag(String tagname) {
		if(!tagname.equals(null)){
			Object[] params = {tagname};
			return new MessageFormat(imageIdFromFreeTag).format(params);
		}
		return null;
	}

	/**
	 * Getter
	 * @param taxonomy
	 * @param tagname
	 * @return the imageIdListFromPreDefinedTag
	 */
	public String getImageIdListFromPreDefinedTag(String taxonomy, String tagname) {
		if(!taxonomy.equals(null) && !tagname.equals(null)){
			Object[] params = {taxonomy,tagname};
			return new MessageFormat(imageIdListFromPreDefinedTag).format(params);
		}
		return null;
	}

	/**
	 * Getter
	 * @param id
	 * @return the imageURLFromId
	 */
	public String getImageURLFromId(String id) {
		if(!id.equals(null)){
			Object[] params = {id};
			return new MessageFormat(imageURLFromId).format(params);
		}
		return null;
	}

	/**
	 * Getter.
	 * @param URL
	 * @return the imageIdFromURL
	 */
	public String getImageIdFromURL(String URL) {
		if(!URL.equals(null)){
			Object[] params = {URL};
			return new MessageFormat(imageIdFromURL).format(params);
		}
		return null;
	}

	/**
	 * @return the nextImageId
	 */
	public String getNextImageId() {
		return nextImageId;
	}

	/**
	 * @return the nextVideoId
	 */
	public String getNextVideoId() {
		return nextVideoId;
	}

	/**
	 * @return the nextNoticeId
	 */
	public String getNextNoticeId() {
		return nextNoticeId;
	}

	/**
	 * @return the nextUserId
	 */
	public String getNextUserId() {
		return nextUserId;
	}

	/**
	 * Getter
	 * @param id
	 * @param owner
	 * @param title
	 * @return the addBasicImage
	 */
	public String getAddBasicImage(String id, String owner, String title) {
		if(!id.equals(null) && !owner.equals(null) && !title.equals(null)){
			Object[] params = {id,owner,title};
			return new MessageFormat(addBasicImage).format(params);
		}
		return null;
	}

	/**
	 * 
	 * Getter.
	 * @param id
	 * @return the deleteBasicImage
	 */
	public String getDeleteBasicImage(String id) {
		if(!id.equals(null)){
			Object[] params = {id};
			return new MessageFormat(deleteImage).format(params);
		}
		return null;
	}

	/**
	 * Getter
	 * @param id
	 * @param tagname
	 * @return the addFreeTagToImage
	 */
	public String getAddFreeTagToImage(String id, String tagname) {
		if(!id.equals(null) && !tagname.equals(null)){
			Object[] params = {id,tagname};
			return new MessageFormat(addFreeTagToImage).format(params);
		}
		return null;
	}

	/**
	 * Getter
	 * @param id
	 * @param taxonomy
	 * @param tagname
	 * @return the addPreDefinedTagToImage
	 */
	public String getAddPreDefinedTagToImage(String id, String taxonomy, String tagname) {
		if(!id.equals(null) && !taxonomy.equals(null) && !tagname.equals(null)){
			Object[] params = {id,taxonomy,tagname};
			return new MessageFormat(addPreDefinedTagToImage).format(params);
		}
		return null;
	}

	/**
	 * Getter
	 * @param id
	 * @param tagname
	 * @param initCoordinateX
	 * @param endCoordinateX
	 * @param initCoordinateY
	 * @param endCoordinateY
	 * @return the addFreeRegionTagToImage
	 */
	public String getAddFreeRegionTagToImage(String id, String tagname, String initCoordinateX,
			String endCoordinateX, String initCoordinateY, String endCoordinateY) {
		if(!id.equals(null) && !tagname.equals(null) && !initCoordinateX.equals(null) && 
				!endCoordinateX.equals(null) && !initCoordinateY.equals(null) && !endCoordinateY.equals(null)){
			Object[] params = {id,tagname,initCoordinateX,endCoordinateX,initCoordinateY,endCoordinateY};
			return new MessageFormat(addFreeRegionTagToImage).format(params);
		}
		return null;
	}

	/**
	 * Getter
	 * @param id
	 * @param taxonomy
	 * @param tagname
	 * @param initCoordinateX
	 * @param endCoordinateX
	 * @param initCoordinateY
	 * @param endCoordinateY
	 * @return the addPreDefinedRegionTagToImage
	 */
	public String getAddPreDefinedRegionTagToImage(String id, String taxonomy, String tagname, String initCoordinateX,
			String endCoordinateX, String initCoordinateY, String endCoordinateY) {
		if(!id.equals(null) && !taxonomy.equals(null) && !tagname.equals(null) && !initCoordinateX.equals(null) && 
				!endCoordinateX.equals(null) && !initCoordinateY.equals(null) && !endCoordinateY.equals(null)){
			Object[] params = {id,taxonomy,tagname,initCoordinateX,endCoordinateX,initCoordinateY,endCoordinateY};
			return new MessageFormat(addPreDefinedRegionTagToImage).format(params);
		}
		return null;
	}

	/**
	 * Getter
	 * @param id
	 * @param tagname
	 * @return the deleteTagToImage
	 */
	public String getDeleteTagToImage(String id, String tagname) {
		if(!id.equals(null) && !tagname.equals(null)){
			Object[] params = {id,tagname};
			return new MessageFormat(deleteTagToImage).format(params);
		}
		return null;
	}

	/**
	 * Getter.
	 * @param id
	 * @param exifField
	 * @param exifValue
	 * @return the modifyImageExif
	 */
	public String getModifyImageExif(String id, String exifField, String exifValue) {
		if(!id.equals(null) && !exifField.equals(null) && !exifValue.equals(null)){
			Object[] params = {id,exifField,exifValue};
			return new MessageFormat(modifyImageExif).format(params);
		}
		return null;
	}

	/**
	 * Getter.
	 * @param id
	 * @param propertyField
	 * @param propertyValue
	 * @return the modifyImageProperties
	 */
	public String getModifyImageProperties(String id, String propertyField, String propertyValue) {
		if(!id.equals(null) && !propertyField.equals(null) && !propertyValue.equals(null)){
			Object[] params = {id,propertyField,propertyValue};
			return new MessageFormat(modifyImageProperties).format(params);
		}
		return null;
	}

	/**
	 * Getter
	 * @param id
	 * @param rankField
	 * @param rankValue
	 * @return the modifyImageRank
	 */
	public String getModifyImageRank(String id, String rankField, String rankValue) {
		if(!id.equals(null) && !rankField.equals(null) && !rankValue.equals(null)){
			Object[] params = {id,rankField,rankValue};
			return new MessageFormat(modifyImageRank).format(params);
		}
		return null;
	}

    /**
     * Getter.
     * @param URL
     * @return the videoIdFromURL
     */
    public String getVideoIdFromURL(String URL) {
        if(!URL.equals(null)){
            Object[] params = {URL};
            return new MessageFormat(videoIdFromURL).format(params);
        }
        return null;
    }

	/**
	 * Getter.
	 * @param id
	 * @param owner
	 * @param title
	 * @return the addBasicVideo
	 */
	public String getAddBasicVideo(String id, String owner, String title) {
		if(!id.equals(null) && !owner.equals(null) && !title.equals(null)){
			Object[] params = {id,owner,title};
			return new MessageFormat(addBasicVideo).format(params);
		}
		return null;
	}

	/**
	 * Getter.
	 * @param id
	 * @return the deleteVideo
	 */
	public String getDeleteVideo(String id) {
		if(!id.equals(null)){
			Object[] params = {id};
			return new MessageFormat(deleteVideo).format(params);
		}
		return null;
	}

	/**
	 * Getter.
	 * @param id
	 * @param fieldName
	 * @param fieldValue
	 * @return the modifyVideoField
	 */
	public String getModifyVideoField(String id, String fieldName, String fieldValue) {
		if(!id.equals(null) && !fieldName.equals(null) && !fieldValue.equals(null)){
			Object[] params = {id,fieldName,fieldValue};
			return new MessageFormat(modifyVideoField).format(params);
		}
		return null;
	}

	/**
	 * Getter.
	 * @param id
	 * @param fieldName
	 * @param fieldValue
	 * @return the modifyVideoRate
	 */
	public String getModifyVideoRate(String id, String fieldName, String fieldValue) {
		if(!id.equals(null) && !fieldName.equals(null) && !fieldValue.equals(null)){
			Object[] params = {id,fieldName,fieldValue};
			return new MessageFormat(modifyVideoRate).format(params);
		}
		return null;
	}

	/**
	 * Getter.
	 * @param id
	 * @param tagname
	 * @return the addFreeTagToVideo
	 */
	public String getAddFreeTagToVideo(String id, String tagname) {
		if(!id.equals(null) && !tagname.equals(null)){
			Object[] params = {id,tagname};
			return new MessageFormat(addFreeTagToVideo).format(params);
		}
		return null;
	}

	/**
	 * Getter.
	 * @param id
	 * @param taxonomy
	 * @param tagname
	 * @return the addPreDefinedTagToVideo
	 */
	public String getAddPreDefinedTagToVideo(String id, String taxonomy, String tagname) {
		if(!id.equals(null) && !taxonomy.equals(null) && !tagname.equals(null)){
			Object[] params = {id,taxonomy,tagname};
			return new MessageFormat(addPreDefinedTagToVideo).format(params);
		}
		return null;
	}

	/**
	 * Getter.
	 * @param id
	 * @param tagname
	 * @return the deleteTagToVideo
	 */
	public String getDeleteTagToVideo(String id, String tagname) {
		if(!id.equals(null) && !tagname.equals(null)){
			Object[] params = {id,tagname};
			return new MessageFormat(deleteTagToVideo).format(params);
		}
		return null;
	}

	/**
	 * Getter.
	 * @param id
	 * @return the deleteNotice
	 */
	public String getDeleteNotice(String id) {
		if(!id.equals(null)){
			Object[] params = {id};
			return new MessageFormat(deleteNotice).format(params);
		}
		return null;
	}

	/**
	 * Getter.
	 * @param id
	 * @param firstName
	 * @param lastName
	 * @param nickName
	 * @param userDirectory
	 * @param email
	 * @return the addUser
	 */
	public String getAddUser(String id, String firstName, String lastName, 
			String nickName, String userDirectory, String email) {
		if(!id.equals(null) && !firstName.equals(null) && !lastName.equals(null) &&
				!nickName.equals(null) && !userDirectory.equals(null) && !email.equals(null)){
			Object[] params = {id,firstName,lastName,nickName,userDirectory,email};
			return new MessageFormat(addUser).format(params);
		}
		return null;
	}

	/**
	 * Getter.
	 * @param id
	 * @return the deleteUser
	 */
	public String getDeleteUser(String id) {
		if(!id.equals(null)){
			Object[] params = {id};
			return new MessageFormat(deleteUser).format(params);
		}
		return null;
	}

	/**
	 * Getter.
	 * @param id
	 * @param fieldName
	 * @param fieldValue
	 * @return the modifyUserField
	 */
	public String getModifyUserField(String id, String fieldName, String fieldValue) {
		if(!id.equals(null) && !fieldName.equals(null) && !fieldValue.equals(null)){
			Object[] params = {id,fieldName,fieldValue};
			return new MessageFormat(modifyUserField).format(params);
		}
		return null;
	}

	/**
	 * Getter.
	 * @param id
	 * @param fieldName
	 * @param fieldValue
	 * @return the modifyUserName
	 */
	public String getModifyUserName(String id, String fieldName, String fieldValue) {
		if(!id.equals(null) && !fieldName.equals(null) && !fieldValue.equals(null)){
			Object[] params = {id,fieldName,fieldValue};
			return new MessageFormat(modifyUserName).format(params);
		}
		return null;
	}	
}
